package com.srwl.mytx.activity;

import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.srwl.mytx.R;
import com.srwl.mytx.utils.GlideLoadUtils;

import java.util.LinkedHashMap;

import cn.jzvd.JZDataSource;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;
import qiu.niorgai.StatusBarCompat;

public class FullScreenVideoPlayActivity extends BaseActivity {


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_screen_video);
        String videoPath = getIntent().getStringExtra("videoPath");
        JzvdStd videoPlayer = findViewById(R.id.video_player);
        StatusBarCompat.translucentStatusBar(this, true);

        ViewGroup.LayoutParams params = videoPlayer.getLayoutParams();
        params.height = getResources().getDisplayMetrics().heightPixels;//设置videoPlayer 高度为屏幕可见高度 比如显示底部导航栏的手机，导航栏128像素的高度，那么这儿获取的 heightPixels 为1792
        LinkedHashMap map = new LinkedHashMap();
//        String proxyUrl = MyApplication.getProxy(this).getProxyUrl(topic.getVideo());//视频缓存代理
        map.put("高清", videoPath);
        JZDataSource jzDataSource = new JZDataSource(map, "");
        jzDataSource.looping = true;
        // jzDataSource.currentUrlIndex = 2;
        videoPlayer.setUp(jzDataSource, JzvdStd.SCREEN_FULLSCREEN);
        videoPlayer.hideAllViewAdaptFullScreen();
        videoPlayer.thumbImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        JzvdStd.setVideoImageDisplayType(Jzvd.VIDEO_IMAGE_DISPLAY_TYPE_FILL_CROP);
        //Glide.with(this).load(videoPath).into(videoPlayer.thumbImageView);
        GlideLoadUtils.glideLoad(this,videoPath,videoPlayer.thumbImageView);
        videoPlayer.startVideo();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        JzvdStd.resetAllVideos();
    }
}
